package com.witframework.core.logic;

import java.util.Collection;
import java.util.List;

import com.witframework.WitServiceException;
import com.witframework.core.ServiceCallback;
import com.witframework.core.persistence.ISimpleHibernateDao;


public class SimpleBaseService extends BaseService implements ISimpleBaseService{	
	
	
	public ISimpleHibernateDao getSimpleHibernateDao(){
		return (ISimpleHibernateDao)super.getDao();
	}
	/* (non-Javadoc)
	 * @see com.witframework.core.logic.ISimpleBaseServicea#save(java.lang.Object, com.witframework.core.logic.ServiceCallback)
	 */	
	public String save(final Object entity,final ServiceCallback callback) throws WitServiceException {		

		return getSimpleHibernateDao().save(entity,callback);
				
	}
	
	/* (non-Javadoc)
	 * @see com.witframework.core.logic.ISimpleBaseServicea#update(java.lang.Object, com.witframework.core.logic.ServiceCallback)
	 */
	public void update(final Object entity,final ServiceCallback callback) throws WitServiceException {
		 
		getSimpleHibernateDao().save(entity,callback);
			
	}
	
	/* (non-Javadoc)
	 * @see com.witframework.core.logic.ISimpleBaseServicea#saveOrUpdate(java.lang.Object, com.witframework.core.logic.ServiceCallback)
	 */
	public String saveOrUpdate(Object entity,ServiceCallback callback) throws WitServiceException {	
		
		 return getSimpleHibernateDao().saveOrUpdate(entity,callback);		
		
	}
	
	/* (non-Javadoc)
	 * @see com.witframework.core.logic.ISimpleBaseServicea#saveOrUpdate(java.util.List, com.witframework.core.logic.ServiceCallback)
	 */
	public int saveOrUpdateAll(List entityList,ServiceCallback callback) throws WitServiceException {		
		getSimpleHibernateDao().saveOrUpdateAll(entityList,callback);		
		return entityList.size();
	}
	
	/* (non-Javadoc)
	 * @see com.witframework.core.logic.ISimpleBaseServicea#deleteById(java.lang.String, com.witframework.core.logic.ServiceCallback)
	 */
	public void deleteById(final String id,ServiceCallback callback) throws WitServiceException {		
		getSimpleHibernateDao().deleteById(id,callback);
		
	}
	
	/* (non-Javadoc)
	 * @see com.witframework.core.logic.ISimpleBaseServicea#delete(java.lang.Object, com.witframework.core.logic.ServiceCallback)
	 */
	public void delete(Object entity,ServiceCallback callback) throws WitServiceException {		
		getSimpleHibernateDao().delete(entity,callback);
		
	}
	
	/* (non-Javadoc)
	 * @see com.witframework.core.logic.ISimpleBaseServicea#deleteBy(java.lang.String, java.lang.Object, com.witframework.core.logic.ServiceCallback)
	 */
	public void deleteBy(String propertyName, Object value,ServiceCallback callback)	throws WitServiceException {
		getSimpleHibernateDao().deleteBy(propertyName, value,callback);		
	}
	
	/* (non-Javadoc)
	 * @see com.witframework.core.logic.ISimpleBaseServicea#deleteAll(java.util.Collection, com.witframework.core.logic.ServiceCallback)
	 */
	public void deleteAll(Collection  entities,ServiceCallback callback) throws WitServiceException {
		
		getSimpleHibernateDao().deleteAll(entities,callback);
		
	}
	
	/* (non-Javadoc)
	 * @see com.witframework.core.logic.ISimpleBaseServicea#deleteAllByIds(com.witframework.core.logic.ServiceCallback, java.lang.String)
	 */
	public void deleteAllByIds(ServiceCallback callback,String... ids) throws WitServiceException {
		
		getSimpleHibernateDao().deleteAllByIds(callback,ids);
		
	}
	/* (non-Javadoc)
	 * @see com.witframework.core.logic.ISimpleBaseServicea#merge(java.lang.Object, com.witframework.core.logic.ServiceCallback)
	 */
	public Object merge(Object entity) throws WitServiceException {		
		return getSimpleHibernateDao().merge(entity);
		
	}

	
}